//
//  AZURLRequest.h
//  AZNetwork
//
//  Created by GorXion on 2018/4/2.
//  Copyright © 2018年 gaoX. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFURLRequestSerialization.h>
#import <AFNetworking/AFURLResponseSerialization.h>

typedef NS_ENUM(NSInteger, AZHTTPMethod) {
    AZHTTPMethodGet = 0,
    AZHTTPMethodPost,
    AZHTTPMethodUpload
};

@interface AZURLRequest : NSObject

@property (nonatomic, copy, readonly) NSString *URLString;
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *parameters;

@property (nonatomic, assign) AZHTTPMethod method;

@property (nonatomic, strong) AFHTTPRequestSerializer<AFURLRequestSerialization> *requestSerializer;
@property (nonatomic, strong) AFHTTPResponseSerializer<AFURLResponseSerialization> *responseSerializer;

@property (nonatomic, strong) void (^constructingBodyWithBlock)(id<AFMultipartFormData> formData);

+ (instancetype)requestWithBaseURL:(NSURL *)baseURL
                              path:(NSString *)path
                        parameters:(NSDictionary *)parameters;

- (void)startWithSuccess:(void (^)(id response))success
                 failure:(void (^)(NSError *error))failure;

- (void)startWithCache:(void (^)(id cachedData))cache
               success:(void (^)(id response))success
               failure:(void (^)(NSError *error))failure;

@end
